<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('新增在职人员分析')"/>
    <th:block th:include="include :: datetimepicker-css"/>
    <th:block th:include="include :: select2-css"/>
    <th:block th:include="include :: bootstrap-select-css"/>
</head>
<style>
    input::-webkit-outer-spin-button, input::-webkit-inner-spin-button {
        -webkit-appearance: none;
    }

    input[type="number"] {
        -moz-appearance: textfield;
    }

</style>
<body>
<div class="wrapper wrapper-content ibox-content">
    <form class="form-horizontal m" id="empQuit-edit" AUTOCOMPLETE="OFF">
        <input th:value="${data.id}" id="id" name="id" class="form-control" type="hidden"/>
        <h4 class="form-header h4">基本信息</h4>
        <div class="form-group">
            <div class="col-sm-12">
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label">单位：</label>
                    <div class="col-sm-8">
                        <select name="compId" id="compId" class="form-control noselect2" disabled>
                            <option value="">请选择</option>
                            <option th:each="pro:${userComp}"
                                    th:selected="${data.compId==pro.compId}"
                                    th:value="${pro.compId}"
                                    th:text="${pro.compName}"></option>
                        </select>
                    </div>
                </div>
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label" style="white-space: nowrap;">本月总离职人数：</label>
                    <div class="col-sm-8">
                        <input th:value="${data.monthTotalQuitNum}" id="monthTotalQuitNum" name="monthTotalQuitNum"
                               class="form-control"
                               type="number" disabled>
                    </div>
                </div>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-12">
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label" style="white-space: nowrap;">年份：</label>
                    <div class="col-sm-8">
                        <input th:value="${data.years}" id="years" name="years"
                               class="form-control"
                               type="number" disabled>
                    </div>
                </div>
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label" style="white-space: nowrap;">月份：</label>
                    <div class="col-sm-8">
                        <input th:value="${data.months}" id="months" name="months"
                               class="form-control"
                               type="number" disabled>
                    </div>
                </div>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-12">
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label" style="white-space: nowrap;">高层管理：</label>
                    <div class="col-sm-8">
                        <input th:value="${data.highNum}" id="highNum" name="highNum"
                               class="form-control"
                               placeholder="请输入高层管理人数"
                               type="number" required>
                    </div>
                </div>
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label" style="white-space: nowrap;">中层管理：</label>
                    <div class="col-sm-8">
                        <input th:value="${data.middleNum}" id="middleNum" name="middleNum"
                               class="form-control"
                               placeholder="请输入中层管理人数"
                               type="number" required>
                    </div>
                </div>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-12">

                <div class="col-sm-6">
                    <label class="col-sm-4 control-label" style="white-space: nowrap;">基层管理：</label>
                    <div class="col-sm-8">
                        <input th:value="${data.basicNum}" id="basicNum" name="basicNum"
                               class="form-control"
                               placeholder="请输入基层管理人数"
                               type="number" required>
                    </div>
                </div>
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label" style="white-space: nowrap;">工人人数：</label>
                    <div class="col-sm-8">
                        <input th:value="${data.workerNum}" id="workerNum" name="workerNum"
                               class="form-control"
                               placeholder="请输入工人人数"
                               type="number" required>
                    </div>
                </div>
            </div>
        </div>

        <div class="form-group">
            <div class="col-sm-12">

                <div class="col-sm-6">
                    <label class="col-sm-4 control-label" style="white-space: nowrap;">后勤(不含安保)：</label>
                    <div class="col-sm-8">
                        <input th:value="${data.logisticsNum}" id="logisticsNum" name="logisticsNum"
                               class="form-control"
                               placeholder="请输入后勤人数"
                               type="number" required>
                    </div>
                </div>
            </div>
        </div>
        <h4 class="form-header h4">性别结构</h4>
        <div class="form-group">
            <div class="col-sm-12">
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label" style="white-space: nowrap;">男人数：</label>
                    <div class="col-sm-8">
                        <input th:value="${data.maleNum}" id="maleNum" name="maleNum"
                               class="form-control"
                               placeholder="请输入男人数"
                               type="number" required>
                    </div>
                </div>
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label" style="white-space: nowrap;">女人数：</label>
                    <div class="col-sm-8">
                        <input th:value="${data.femaleNum}" id="femaleNum" name="femaleNum"
                               class="form-control"
                               placeholder="请输入女人数"
                               type="number" required>
                    </div>
                </div>
            </div>
        </div>
        <h4 class="form-header h4">工龄分布</h4>
        <div class="form-group">
            <div class="col-sm-12">
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label" style="white-space: nowrap;">＜1年：</label>
                    <div class="col-sm-8">
                        <input th:value="${data.oneYearLowerNum}" id="oneYearLowerNum" name="oneYearLowerNum"
                               class="form-control"
                               placeholder="请输入＜1年人数"
                               type="number" required>
                    </div>
                </div>
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label" style="white-space: nowrap;">1年≥~＜3年：</label>
                    <div class="col-sm-8">
                        <input th:value="${data.oneThreeNum}" id="oneThreeNum" name="oneThreeNum"
                               class="form-control"
                               placeholder="请输入1年≥~＜3年人数"
                               type="number" required>
                    </div>
                </div>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-12">
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label" style="white-space: nowrap;">3年≥~＜5年：</label>
                    <div class="col-sm-8">
                        <input th:value="${data.threeFiveNum}" id="threeFiveNum" name="threeFiveNum"
                               class="form-control"
                               placeholder="请输入3年≥~＜5年人数"
                               type="number" required>
                    </div>
                </div>
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label" style="white-space: nowrap;">5年≥~＜10年：</label>
                    <div class="col-sm-8">
                        <input th:value="${data.fiveTenNum}" id="fiveTenNum" name="fiveTenNum"
                               class="form-control"
                               placeholder="请输入5年≥~＜10年人数"
                               type="number" required>
                    </div>
                </div>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-12">
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label" style="white-space: nowrap;">≥10年：</label>
                    <div class="col-sm-8">
                        <input th:value="${data.tenYearUpperNum}" id="tenYearUpperNum" name="tenYearUpperNum"
                               class="form-control"
                               placeholder="请输入≥10年人数"
                               type="number" required>
                    </div>
                </div>

            </div>
        </div>
        <h4 class="form-header h4">年龄分布</h4>
        <div class="form-group">
            <div class="col-sm-12">
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label" style="white-space: nowrap;">＜30岁：</label>
                    <div class="col-sm-8">
                        <input th:value="${data.twentyThirtyAgeNum}" id="twentyThirtyAgeNum" name="twentyThirtyAgeNum"
                               class="form-control"
                               placeholder="请输入＜30岁人数"
                               type="number" required>
                    </div>
                </div>
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label" style="white-space: nowrap;">30岁≥~＜40岁：</label>
                    <div class="col-sm-8">
                        <input th:value="${data.thirtyFortyAgeNum}" id="thirtyFortyAgeNum" name="thirtyFortyAgeNum"
                               class="form-control"
                               placeholder="请输入30岁≥~＜40岁人数"
                               type="number" required>
                    </div>
                </div>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-12">
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label" style="white-space: nowrap;">40岁≥~＜50岁：</label>
                    <div class="col-sm-8">
                        <input th:value="${data.fortyFiftyAgeNum}" id="fortyFiftyAgeNum" name="fortyFiftyAgeNum"
                               class="form-control"
                               placeholder="请输入40岁≥~＜50岁人数"
                               type="number" required>
                    </div>
                </div>
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label" style="white-space: nowrap;">≥50岁：</label>
                    <div class="col-sm-8">
                        <input th:value="${data.fiftyUpperAgeNum}" id="fiftyUpperAgeNum" name="fiftyUpperAgeNum"
                               class="form-control"
                               placeholder="请输入≥50岁人数"
                               type="number" required>
                    </div>
                </div>
            </div>
        </div>
        <h4 class="form-header h4">学历分布</h4>
        <div class="form-group">
            <div class="col-sm-12">
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label" style="white-space: nowrap;">高中及以下(含中专)：</label>
                    <div class="col-sm-8">
                        <input th:value="${data.highLowerSchoolNum}" id="highLowerSchoolNum" name="highLowerSchoolNum"
                               class="form-control"
                               placeholder="请输入高中及以下人数"
                               type="number" required>
                    </div>
                </div>
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label" style="white-space: nowrap;">大专人数：</label>
                    <div class="col-sm-8">
                        <input th:value="${data.juniorCollegeSchoolNum}" id="juniorCollegeSchoolNum"
                               name="juniorCollegeSchoolNum"
                               class="form-control"
                               placeholder="请输入大专人数"
                               type="number" required>
                    </div>
                </div>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-12">
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label" style="white-space: nowrap;">本科人数：</label>
                    <div class="col-sm-8">
                        <input th:value="${data.undergraduateSchoolNum}" id="undergraduateSchoolNum"
                               name="undergraduateSchoolNum"
                               class="form-control"
                               placeholder="请输入本科人数"
                               type="number" required>
                    </div>
                </div>
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label" style="white-space: nowrap;">本科以上：</label>
                    <div class="col-sm-8">
                        <input th:value="${data.undergraduateUpperSchoolNum}" id="undergraduateUpperSchoolNum"
                               name="undergraduateUpperSchoolNum"
                               class="form-control"
                               placeholder="请输入本科以上人数"
                               type="number" required>
                    </div>
                </div>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: datetimepicker-js"/>
<th:block th:include="include :: select2-js"/>
<script type="text/javascript">
    var prefix = ctx + 'empQuit';
    var peopleSum;//基本信息人数合计
    var sexSum;//性别人数合计
    var workingSum;//工龄人数合计
    var ageSum;//年龄结构人数合计
    var educationSum;//学历结构人数合计
    var monthTotalQuitNum;//本月总离职人数
    $(function () {
        monthTotalQuitNum=Number($("#monthTotalQuitNum").val());
    })
    function validform(formId) {
        return $(formId).validate()
    }

    function submitHandler() {
        peopleSum = Number($("#highNum").val()) + Number($("#middleNum").val()) + Number($("#basicNum").val()) + Number($("#workerNum").val()) + Number($("#logisticsNum").val());
        sexSum = Number($("#maleNum").val()) + Number($("#femaleNum").val());
        workingSum = Number($("#oneYearLowerNum").val()) + Number($("#oneThreeNum").val()) + Number($("#threeFiveNum").val()) + Number($("#fiveTenNum").val()) + Number($("#tenYearUpperNum").val());
        ageSum = Number($("#twentyThirtyAgeNum").val()) + Number($("#thirtyFortyAgeNum").val()) + Number($("#fortyFiftyAgeNum").val()) + Number($("#fiftyUpperAgeNum").val());
        educationSum = Number($("#highLowerSchoolNum").val()) + Number($("#juniorCollegeSchoolNum").val()) + Number($("#undergraduateSchoolNum").val()) + Number($("#undergraduateUpperSchoolNum").val());

        if (validform("#empQuit-edit").form()) {
            if (peopleSum != monthTotalQuitNum) {
                alert("请检查 高层、中层、基层、工人、后勤人数是否等于总离职人数！");
                return false
            }
            if (sexSum != monthTotalQuitNum) {
                alert("请检查性别结构人数是否等于总离职人数！");
                return false
            }
            if (workingSum != monthTotalQuitNum) {
                alert("请检查工龄结构人数是否等于总离职人数！");
                return false
            }
            if (ageSum != monthTotalQuitNum) {
                alert("请检查年龄结构人数是否等于总离职人数！");
                return false
            }
            if (educationSum != monthTotalQuitNum) {
                alert("请检查学历结构人数是否等于总离职人数！");
                return false
            } else {
                $("input").removeAttr('disabled');
                $("select").removeAttr('disabled');
                var data = $("#empQuit-edit").serializeArray();
                $.operate.save(prefix + "/edit", data);
                //parent.sums();
            }

        }
    }
</script>
</body>
</html>